package com.xdcplus.web.controller.device;


import com.xdcplus.exceptions.domain.ResponseVO;
import com.xdcplus.mom.controller.AbstractController;
import com.xdcplus.web.common.pojo.dto.device.DevicePerformanceFilterDTO;
import com.xdcplus.web.common.pojo.vo.device.DeviceFaultDetailVO;
import com.xdcplus.web.common.pojo.vo.device.DevicePerformanceVO;
import com.xdcplus.web.service.device.DevicePerformanceService;
import com.xdcplus.web.service.qa.QaMtrlBatchReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 设备性能(devicePerformance)服务控制层
 *
 * @author Devin.Sang
 * @since 2024-01-24 11:44:30
 */
@Api(tags = "设备性能(devicePerformance)")
@Slf4j
@Validated
@RestController
@AllArgsConstructor
@RequestMapping("devicePerformance")
public class DevicePerformanceController extends AbstractController {

    @Autowired
    private DevicePerformanceService devicePerformanceService;

    @ApiOperation("获取设备性能分析")
    @PostMapping(value = "/queryPerformance", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseVO<List<DevicePerformanceVO>> queryPerformance(@RequestBody DevicePerformanceFilterDTO devicePerformanceFilterDTO) {
        log.info("queryDetail devicePerformanceFilterDTO:{}", devicePerformanceFilterDTO);
        return ResponseVO.success(devicePerformanceService.queryDevicePerformanceData(devicePerformanceFilterDTO));
    }

    /**
     * 临时需求，变更为查询设备异常单
     * @param devicePerformanceFilterDTO
     * @return
     */
    @ApiOperation("获取设备维修单")
    @PostMapping(value = "/queryDeviceRepairDetail", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseVO<List<DeviceFaultDetailVO>> queryDeviceRepairDetail(@RequestBody DevicePerformanceFilterDTO devicePerformanceFilterDTO) {
        log.info("queryFaultDetail devicePerformanceFilterDTO:{}", devicePerformanceFilterDTO);
        return ResponseVO.success(devicePerformanceService.queryDeviceRepairDetail(devicePerformanceFilterDTO));
    }


    @ApiOperation("获取设备故障详情")
    @PostMapping(value = "/queryFaultDetail", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseVO<List<DeviceFaultDetailVO>> queryFaultDetail(@RequestBody DevicePerformanceFilterDTO devicePerformanceFilterDTO) {
        log.info("queryFaultDetail devicePerformanceFilterDTO:{}", devicePerformanceFilterDTO);
        return ResponseVO.success(devicePerformanceService.queryDeviceFaultDetail(devicePerformanceFilterDTO));
    }

}
